<template>
  <div class="view-schedule content-bg">
    <el-table :data="tableData"
              border
              :fit="true"
              style="width: 100%">
      <el-table-column label="日期"
                       prop="date">
      </el-table-column>
      <el-table-column label="日程"
                       prop="schedule">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini"
                     type="primary"
                     @click="handleEdit(scope.$index, scope.row)">修改</el-button>
          <el-button size="mini"
                     type="danger"
                     @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
      </el-table>
      <div class="pagination-box">
      <el-pagination background
                     layout="total, prev, pager, next"
                     :total="1000">
      </el-pagination>
    </div>
    <el-dialog title="修改信息"
               :visible.sync="dialogVisible"
               width="40%"
               :before-close="handleClose">
               <el-form ref="form"
             :model="form"
             :rules="rules"
             label-width="80px">
      <el-form-item label="日期" prop="date">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.date" style="width: 100%;"></el-date-picker>
      </el-form-item>
      <el-form-item label="日程" prop="schedule">
        <el-input type="textarea"  v-model="form.schedule"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary"
                   @click="onSubmit">提交</el-button>
        <el-button @click="handleClose">取消</el-button>
      </el-form-item>
    </el-form>
    </el-dialog>

  </div>
</template>
<script lang="js">
export default {
    data(){
      return{
        tableData: [
        {
          date:'2023-5-6',
          schedule: '找机电维修',
        }],
        form: {
          date: '2023-5-6',
          schedule: '找机电维修'
        },
        rules: {
          date: [
            { required: true, message: '请输入日期', trigger: 'blur' }
          ],
          schedule:[
          { required: true, message: '请输入日程', trigger: 'blur' }
          ]
        },
        dialogVisible: false
      }
    },
    methods: {
      handleEdit(index, row) {
        this.dialogVisible = true;
      },
      handleDelete(index, row) {
          this.$confirm('确定要删除吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error'
        }).then(() => {
          // 访问接口
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消成功'
          });
        });
      },
      onSubmit(){
        // 访问接口
      },
      handleClose(){
        this.dialogVisible = false;
      }
    }

}
</script>
<style lang="scss" scoped>
</style>
